package com.sl.biz.modular.process.dao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sl.biz.modular.process.dao.domain.entity.ProcessRelationConfigDO;
import com.sl.biz.modular.process.dao.mapper.ProcessRelationConfigMapper;
import com.sl.biz.modular.process.dao.service.ProcessRelationConfigDaoService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class ProcessRelationConfigDaoServiceImpl extends ServiceImpl<ProcessRelationConfigMapper, ProcessRelationConfigDO> implements ProcessRelationConfigDaoService {
    @Override
    public List<ProcessRelationConfigDO> queryByProcessIdsAndBizType(String bizType, List<String> processIds) {
        LambdaQueryWrapper<ProcessRelationConfigDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(ProcessRelationConfigDO::getBizType, bizType);
        lambdaQueryWrapper.in(ProcessRelationConfigDO::getProcessId, processIds);
        List<ProcessRelationConfigDO> processRelationConfigDOS = baseMapper.selectList(lambdaQueryWrapper);
        return processRelationConfigDOS;
    }

    @Override
    public List<ProcessRelationConfigDO> queryByBizIdAndBizType(String bizId, String bizType) {
        LambdaQueryWrapper<ProcessRelationConfigDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(ProcessRelationConfigDO::getBizType, bizType);
        lambdaQueryWrapper.eq(ProcessRelationConfigDO::getBizId, bizId);
        List<ProcessRelationConfigDO> processRelationConfigDOS = baseMapper.selectList(lambdaQueryWrapper);
        return processRelationConfigDOS;
    }

    @Override
    public Boolean removeByBizAndAndBizType(String bizId, String bizType) {
        LambdaUpdateWrapper<ProcessRelationConfigDO> lambdaQueryWrapper = new LambdaUpdateWrapper<>();
        lambdaQueryWrapper.eq(ProcessRelationConfigDO::getBizType, bizType);
        lambdaQueryWrapper.eq(ProcessRelationConfigDO::getBizId, bizId);
        return super.remove(lambdaQueryWrapper);
    }
}
